package com.cn.web.controller.bc;

import com.alibaba.fastjson2.JSONObject;

import com.cn.bean.pojo.bc.Kh;
import com.cn.service.server.bc.GetKhServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
public class GetKhController {
    private final GetKhServer getKhServer;

    @Autowired
    public GetKhController(GetKhServer getKhServer) {
        this.getKhServer = getKhServer;
    }

    @RequestMapping("/get/Kh")
    @ResponseBody
    public List<Kh> getKh(@RequestBody JSONObject jsonObject) {
        Integer page = jsonObject.getInteger("page");
        Integer limit = jsonObject.getInteger("limit");
        String khbm = jsonObject.getString("khbm");
        String khmc = jsonObject.getString("khmc");
        khbm = (khbm != null) ? khbm : "";
        khmc = (khmc != null) ? khmc : "";


        List<Kh> kh = getKhServer.getKh(khbm, khmc, limit, page);
        return kh;
    }
}
